fix: widen signed_at/signed_by columns to prevent PostgreSQL overflow#15
Merged
bradleygauthier merged 1 commit intomainfrom Mar 17, 2026
Merged
Conversation
…SQL overflow `Seal.seal()` stamps `signed_at` with `datetime.now(UTC)`, whose `.isoformat()` produces 32-character strings (e.g. `2026-03-17T05:24:42.485699+00:00`). Both `CapsuleModel` and `CapsuleModelPG` declared this column as `String(30)`, causing every PostgreSQL write to raise `StorageError: value too long for type character varying(30)`. SQLite was unaffected (it ignores VARCHAR length). Changes: - Widen `signed_at` from String(30) to String(40) in both models - Widen `signed_by` from String(16) to String(32) for headroom (legacy hex fingerprint is exactly 16 chars — zero margin for format changes) - Bump version to 1.5.1 - Add 24 regression tests covering schema introspection, isoformat length validation, and store-retrieve roundtrips for both storage backends - Document storage schema with full column reference in API docs - Add migration SQL for existing PostgreSQL deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
signed_atcolumn (String(30)) was 2 characters too narrow fordatetime.isoformat()output from timezone-aware datetimes (32 chars for UTC+00:00), causingStorageErroron every PostgreSQL write. SQLite was unaffected (it ignores VARCHAR length). Also widenssigned_byfromString(16)toString(32)— the legacy 16-char hex fingerprint had zero headroom.signed_atfromString(30)toString(40)in bothCapsuleModelandCapsuleModelPGsigned_byfromString(16)toString(32)in both modelsType of Change
Checklist
Python reference (
reference/python/)cd reference/python && pytest tests/— 761 passed, 7 skippedcd reference/python && ruff check src/ tests/— All checks passedcd reference/python && mypy src/qp_capsule/— Successcd reference/python && pytest tests/test_golden_fixtures.pyTypeScript reference (
reference/typescript/)General
[1.5.1] - 2026-03-17with Fixed + Migration sectionsProtocol Impact
Migration
For existing PostgreSQL deployments:
New installations get the correct widths automatically via
create_all(). SQLite databases require no action.Test Coverage
24 new regression tests in
test_column_width.py:qp_key_XXXXboth fitsigned_at/signed_bysurviveget,list,get_latestget_all_ordered, keyring format, and post-roundtripverify()